#include "prompterwidget.h"
#include "ui_prompterwidget.h"
#include "WIN32/windowmanager.h"

PrompterWidget::PrompterWidget(QWidget *parent)
    : QWidget(parent), ui(new Ui::PrompterWidget)
{
    ui->setupUi(this);
    ui->textEdit->setPlaceholderText("输入文本，或拖拽txt文件到此处~~\n已有文字设置大小时需选中文本~\n一次只能拖拽暂一个文件~\n暂时只支持txt文件~");
    this->window()->setAcceptDrops(true);

    connect(ui->win_top, &QCheckBox::clicked, this, [this](bool isclicked){
        if(isclicked)
            WindowManager::setWindowTop((HWND)this->window()->winId());
        else
            WindowManager::cancelWindowTop((HWND)this->window()->winId());
    });

    connect(ui->win_capture, &QCheckBox::clicked, this, [this](bool isclicked){
        if(isclicked)
            WindowManager::prohibitWindowCaptured((HWND)this->window()->winId());
        else
            WindowManager::allowWindowCaptured((HWND)this->window()->winId());
    });

    connect(ui->transparent, &QSpinBox::valueChanged, this, [this](qreal value){
        if(value>10.0)
            this->setWindowOpacity(value/100);
    });
    connect(ui->font_size, &QSpinBox::valueChanged, ui->textEdit, &QTextEdit::setFontPointSize); // 设置选中文字大小
}

PrompterWidget::~PrompterWidget()
{
    delete ui;
}
